//
//  DCIMSimpleTextInfoSettingViewController.m
//  xmppBase
//
//  Created by striby on 16/1/27.
//  Copyright © 2016年 com.dc. All rights reserved.
//

#import "DCIMSimpleTextInfoSettingViewController.h"

@interface DCIMSimpleTextInfoSettingViewController ()
{
    UITextField * inputView;
}
@end

@implementation DCIMSimpleTextInfoSettingViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.view.backgroundColor = [UIColor groupTableViewBackgroundColor];
    
    inputView = [[UITextField alloc]initWithFrame:CGRectMake(0, 94, DCDeviceWidth, 35)];
    inputView.backgroundColor = [UIColor whiteColor];
    inputView.borderStyle = UITextBorderStyleNone;
    inputView.delegate=self;
    inputView.text = self.defaultText;
    inputView.clearButtonMode = UITextFieldViewModeWhileEditing;
    [self.view addSubview:inputView];
    
    UIBarButtonItem *rightButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(commit) ];
    
    self.navigationItem.rightBarButtonItem = rightButton;
    
    UIView * leftView =[[UIView alloc]initWithFrame:CGRectMake(0, 0, 10, inputView.frame.size.height)];
    inputView.leftView = leftView;
    
    inputView.leftViewMode = UITextFieldViewModeAlways;
    
    
}


-(void)commit
{
    if (self.inputedText!=nil) {
        self.inputedText(inputView.text);
    }

    [self.navigationController popViewControllerAnimated:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
